package com.logicalthinking.socialmall.controller.admin;

import com.github.chenlijia1111.utils.common.Result;
import com.github.chenlijia1111.utils.core.annos.PropertyCheck;
import com.logicalthinking.socialmall.biz.RoleBiz;
import com.logicalthinking.socialmall.common.vo.requestVo.role.RoleAddParams;
import com.logicalthinking.socialmall.common.vo.requestVo.role.RolePageQueryParams;
import com.logicalthinking.socialmall.common.vo.requestVo.role.RoleUpdateParams;
import com.logicalthinking.socialmall.common.vo.responseVo.role.RoleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 角色表
 *
 * @author chenLiJia
 * @since 2020-02-17 14:43:59
 **/
@RestController
@RequestMapping(value = "admin/role")
@Api(tags = "角色权限")
@PropertyCheck
public class RoleController {


    @Autowired
    private RoleBiz roleBiz;//角色

    /**
     * 添加角色
     *
     * @param params
     * @return
     */
    @PostMapping(value = "add")
    @ApiOperation(value = "添加角色")
    public Result add(@RequestBody RoleAddParams params) {
        return roleBiz.add(params);
    }

    /**
     * 删除角色
     *
     * @param id
     * @return
     */
    @PostMapping(value = "delete")
    @ApiOperation(value = "删除角色")
    public Result delete(Integer id) {
        return roleBiz.delete(id);
    }

    /**
     * 批量删除角色
     *
     * @param idList
     * @return
     */
    @PostMapping(value = "delete/batch")
    @ApiOperation(value = "批量删除角色")
    public Result batchDelete(@RequestBody List<Integer> idList) {
        return roleBiz.batchDelete(idList);
    }

    /**
     * 修改角色
     *
     * @param params
     * @return
     */
    @PostMapping(value = "update")
    @ApiOperation(value = "修改角色")
    public Result update(@RequestBody RoleUpdateParams params) {
        return roleBiz.update(params);
    }

    /**
     * 主键查询角色信息
     *
     * @param id
     * @return
     */
    @GetMapping(value = "findById")
    @ApiOperation(value = "主键查询角色信息",response = RoleVo.class)
    public Result findById(Integer id) {
        return roleBiz.findById(id);
    }

    /**
     * 列表查询角色信息
     *
     * @param params
     * @return
     */
    @GetMapping(value = "listPage")
    @ApiOperation(value = "列表查询角色信息",response = RoleVo.class)
    public Result listPage(RolePageQueryParams params) {
        return roleBiz.listPage(params);
    }

}
